package com.kamkor.interviewer.client;

import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.ui.RootPanel;

/**
 * If application is loading some data from server, it can call this class
 * method to show or hide loading indicator on a page. 
 * 
 * @author kamkor
 *
 */
public class LoadingIndicator {
	/** Loading dom element from Interviewer.html */
	private final static RootPanel loading = RootPanel.get("loading");
	
	/** Span element in loading div that contains loading text info */
	private final static Element loadingTextSpan = loading.getElement().getElementsByTagName("span").getItem(0);	
	
	/**
	 * Changes loading div inner text and sets it to visible
	 * @param loadingText
	 */
	public static void loadingStarted(String loadingText) {			
		loadingTextSpan.setInnerText(loadingText);		
		loading.setVisible(true);
	}
	
	public static void loadingFinished() {
		loading.setVisible(false);
	}

}
